package io.renren.modules.cgs.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.cgs.entity.CgsAccidencheckEntity;
import io.renren.modules.cgs.service.CgsAccidencheckService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;


/**
 * 
 * 
 * @author wxy
 * @email sharonwang_xy@163.com
 * @date 2018-11-29 10:12:51
 */
@RestController
@RequestMapping("cgs/cgsaccidencheck")
public class CgsAccidencheckController {
	@Autowired
	private CgsAccidencheckService cgsAccidencheckService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("cgs:cgsaccidencheck:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<CgsAccidencheckEntity> cgsAccidencheckList = cgsAccidencheckService.queryList(query);
		int total = cgsAccidencheckService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(cgsAccidencheckList, total, query.getLimit(), query.getCurrPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("cgs:cgsaccidencheck:info")
	public R info(@PathVariable("id") String id){
		CgsAccidencheckEntity cgsAccidencheck = cgsAccidencheckService.queryObject(id);
		
		return R.ok().put("cgsAccidencheck", cgsAccidencheck);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("cgs:cgsaccidencheck:save")
	public R save(@RequestBody CgsAccidencheckEntity cgsAccidencheck){
		cgsAccidencheckService.save(cgsAccidencheck);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("cgs:cgsaccidencheck:update")
	public R update(@RequestBody CgsAccidencheckEntity cgsAccidencheck){
		cgsAccidencheckService.update(cgsAccidencheck);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("cgs:cgsaccidencheck:delete")
	public R delete(@RequestBody String[] ids){
		cgsAccidencheckService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
